//
//  ProjectEditViewController.m
//  MagictoLane
//
//  Created by 锋 on 2017/12/22.
//  Copyright © 2017年 HUAYU. All rights reserved.
//

#import "ProjectEditViewController.h"
#import "ProducePointTableViewCell.h"
#import "ProdoceJobDescriptionTableViewCell.h"
#import "AddMachineViewController.h"
#import "AddPointViewController.h"
#import "ProducePointModel.h"
#import "SelectWorkKindModel.h"
#import "AddMachineModel.h"
#import "ProduceLineKindViewController.h"
#import "MyProductionLineViewController.h"
#import "ProduceLineDetailViewController.h"
#import "ProduceMachinesModel.h"
#import "ProduceSpotsModel.h"
#import "AddWorkerViewController.h"
#import "SpecialWorkerViewController.h"
#import "DataPicturesViewController.h"
#import "SelectPictureViewController.h"
#import "CloseAreaViewController.h"
#import "FactoryIntroductionViewController.h"
#import "SelectFactoryViewController.h"
#import "SelectProduceTypeViewController.h"
#import "LoginOrRegisterViewController.h"
#import "PGDatePicker.h"
#import "PGDatePickManager.h"

@interface ProjectEditViewController ()<UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate, UITextViewDelegate, FactoryIntroductionViewControllerDelegate, PGDatePickerDelegate>
{
    NSArray *productionNameArr;
    NSMutableArray *rightProduceNameArr;
    NSMutableArray *spotDetailArr;
    UILabel *dayLabel;
    UILabel *nameLabel;
    UIButton *addProducePointBtn;
    UILabel *jobNameLabel;
    UILabel *workerNameLabel;
    UIButton *workerAddProducePointBtn;
    UIButton *jobAddProducePointBtn;
    
    CGFloat scrollViewOffSetY;
    CGFloat remainingDistanceY;
    CGFloat beforeMigrationY;
    NSArray *nameArr;
    UITextField *textField4;
    UITextField *textField5;
    NSString *str4;
    NSString *str5;
    NSString *str6;
    UIButton *simplePackBtn;
    UIButton *professionPackBtn;
    UITextView *packDetailTextView;
    UIButton *leftSelectBtn;
    UILabel *leftSelectLabel;
    UIButton *rightSelectBtn;
    UILabel *rightSelectLabel;
    CGFloat textViewY;
    BOOL leftBtnIsSelect;
    BOOL rightBtnIsSelect;
    BOOL simplePackIsSelect;
    BOOL professionPackIsSelect;
    BOOL packPictureIsHas;
    SelectProduceTypeModel *selectProduceModel;
    
    NSString *sendAreaStr;
    NSString *acceptAreaStr;
    NSString *produeDetailStr;
    NSString *produceType;
    NSString *projectNameStr;
    NSString *projectBudgetStr;
    NSString *startTimeStr;
    NSString *endTimeStr;
    
    UIView *setUpView;
    NSInteger whichPicker;
    NSDateComponents *startComponent;
    NSDateComponents *endComponent;
    
    NSString *managerPrice;
    UILabel *productTipLabel;
    UILabel *areaLabel;
    UILabel *addressLabel;
}
@property (nonatomic, strong) UITableView *addProductionLineTableView;
@property (nonatomic, strong) SelectWorkKindModel *selectWorkKindModel;
@property (nonatomic, strong) AddMachineModel *addMachineModel;
@property (nonatomic, strong) ProduceLineKindModel *produceLineKindModel;
@property (strong, nonatomic) UILabel *plaLabel;
@property (strong, nonatomic) UILabel *countLabel;
@property (nonatomic, assign) CGFloat height;
@property (nonatomic, strong) NSMutableArray *imageArr;
@property (nonatomic, strong) NSMutableArray *bomsImageArr;
@property (nonatomic, copy) NSString *areaId;
@property (nonatomic, strong) NSDictionary *dic;
@property (strong, nonatomic) NSString *textViewStr;
@end

@implementation ProjectEditViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _height = 183;
    textViewY = 73;
    whichPicker = 1;
    packPictureIsHas = NO;
    leftBtnIsSelect = YES;
    rightBtnIsSelect = NO;
    simplePackIsSelect = YES;
    professionPackIsSelect = NO;
    leftSelectBtn.hidden = YES;
    leftSelectLabel.hidden = YES;
    rightSelectBtn.hidden = YES;
    rightSelectLabel.hidden = YES;
    spotDetailArr = @[].mutableCopy;
    self.imageArr = @[].mutableCopy;
    self.bomsImageArr = @[].mutableCopy;
    self.produceMachineModelArr = @[].mutableCopy;
    self.produceMachineNameArr = @[].mutableCopy;
    self.producePointNameArr = @[].mutableCopy;
    self.produceWorkerNameArr = @[].mutableCopy;
    self.produceWorkerModelArr = @[].mutableCopy;
    self.workNumberArr = @[].mutableCopy;
    self.machineNumberArr = @[].mutableCopy;
    managerPrice = @"";
    acceptAreaStr = @"";
    sendAreaStr = @"";
    produeDetailStr = @"";
    productionNameArr = @[@"项目名称", @"生产类型", @"项目金额", @"项目时间"];
    ProjectDetailModel *detailModel = _projectDetailArr[0];
    str4 = detailModel.expressFee;
    str5 = detailModel.packingFee;
    str6 = detailModel.bomNum;
    
    [self setupMyProductionLineTableView];
    [self setupUI];
    if (_contractorDic) {
        self.navigationController.navigationBar.hidden = NO;
        nameArr = @[@"Bom资料", @"物料编号", @"收货地址", @"物流费用", @"包装费用"];
    } else {
        nameArr = @[@"Bom资料", @"物料编号", @"发布区域", @"收货地址", @"物流费用", @"包装费用"];
    }
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jianpantanchu:) name:UIKeyboardDidShowNotification object:nil];
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jianpanhuishou:) name:UIKeyboardDidHideNotification object:nil];
    if (_specialWorkerModel && ![_specialWorkerModel isKindOfClass:[NSNull class]]) {
        [_produceWorkerNameArr addObject:_specialWorkerModel.name];
        [_workNumberArr addObject:@"1"];
        WorkModel *workModel = [[WorkModel alloc] init];
        workModel.workId = _specialWorkerModel.ID;
        workModel.count = _workNumberArr.lastObject;
        [_produceWorkerModelArr addObject:workModel];
        [_addProductionLineTableView reloadData];
    }
    _specialWorkerModel = nil;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
//    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)setupUI {
    UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"发布" style:UIBarButtonItemStylePlain target:self action:@selector(onClickSendBtn)];
    rightBtn.tintColor = [UIColor whiteColor];
    [rightBtn setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:15], UITextAttributeFont,nil] forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem = rightBtn;
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.title = @"需求发布";
    self.view.backgroundColor = RGB(242, 242, 242);
    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];
    singleTap.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:singleTap];
}

- (void)setupMyProductionLineTableView {
    _addProductionLineTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - STA_NAV_HEIGHT - SCREER_HeiX) style:UITableViewStyleGrouped];
    _addProductionLineTableView.delegate = self;
    _addProductionLineTableView.dataSource = self;
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.000001)];
    view.backgroundColor = [UIColor whiteColor];
    _addProductionLineTableView.tableHeaderView = view;
    _addProductionLineTableView.tableFooterView = view;
    _addProductionLineTableView.backgroundColor = [UIColor whiteColor];
    _addProductionLineTableView.backgroundColor = RGB(242, 242, 242);
    if (@available(iOS 11.0, *)) {
        _addProductionLineTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    _addProductionLineTableView.estimatedRowHeight = 0;
    _addProductionLineTableView.estimatedSectionHeaderHeight = 0;
    _addProductionLineTableView.estimatedSectionFooterHeight = 0;
//    _addProductionLineTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_addProductionLineTableView];
}

- (void)onClickSendBtn {
    NSMutableArray *machinesArr = [NSMutableArray array];
    for (int i = 0; i < _produceMachineModelArr.count; i++) {
        AddMachineModel *model = _produceMachineModelArr[i];
        NSDictionary *dic = @{@"machine" : @{@"id" : model.ID}, @"count" : _machineNumberArr[i]};
        [machinesArr addObject:dic];
    }
    NSMutableArray *spotsArr = [NSMutableArray array];
    [spotsArr addObject:@{@"work" : @{@"id" : @"1", @"name" : @"管理者"}, @"remark" : @"管理者", @"forecastWage":managerPrice}];
    if (_producePointNameArr.count > 0) {
        for (int i = 0; i < _producePointNameArr.count; i++) {
            ProducePointModel *model = _producePointNameArr[i];
            NSDictionary *dic;
            dic = @{@"work" : @{@"id" : model.ID}, @"remark" : model.jobDetailStr, @"manager": @"0", @"forecastWage":model.priceStr};
            [spotsArr addObject:dic];
        }
    }
    NSMutableArray *workGroupsArr = [NSMutableArray array];
    [workGroupsArr addObject:@{@"work" : @{@"id" : @"1"}, @"count" : @"1"}];
    for (int i = 0; i < _produceWorkerModelArr.count; i++) {
        WorkModel *model = _produceWorkerModelArr[i];
        //        ProducePointTableViewCell *cell = [_addProductionLineTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i + 1 inSection:2]];
        NSDictionary *dic = @{@"work" : @{@"id" : model.workId}, @"count" : _workNumberArr[i]};
        [workGroupsArr addObject:dic];
    }
    NSString *packTypeStr;
    NSString *wrapperTypeStr;
    if (simplePackIsSelect) {
        packTypeStr = @"1";
    } else {
        packTypeStr = @"2";
        if (leftBtnIsSelect) {
            wrapperTypeStr = @"1";
        } else {
            wrapperTypeStr = @"1";
        }
    }
    
    if ([projectNameStr isEqualToString:@""] || !projectNameStr) {
        [LTools showMBProgressWithText:@"请输入项目名称" addToView:self.view];
        return;
    }
    NSString *productId;
    if ([selectProduceModel.ID isEqualToString:@""] || [selectProduceModel isKindOfClass:[NSNull class]] || !selectProduceModel.ID) {
        [LTools showMBProgressWithText:@"请选择生产类型" addToView:self.view];
        return;
    } else {
        productId = selectProduceModel.ID;
    }
    
    if ([projectBudgetStr isEqualToString:@""] || !projectBudgetStr) {
        [LTools showMBProgressWithText:@"请输入项目总金额" addToView:self.view];
        return;
    }
    if ([startTimeStr isEqualToString:@""] || !startTimeStr) {
        [LTools showMBProgressWithText:@"请输入开始时间" addToView:self.view];
        return;
    }
    if ([endTimeStr isEqualToString:@""] || !endTimeStr) {
        [LTools showMBProgressWithText:@"请输入结束时间" addToView:self.view];
        return;
    }
    if ([produeDetailStr isEqualToString:@""] || !produeDetailStr) {
        [LTools showMBProgressWithText:@"请输入生产说明" addToView:self.view];
        return;
    }
    if (!machinesArr || [machinesArr isKindOfClass:[NSNull class]] || machinesArr.count==0) {
        [LTools showMBProgressWithText:@"请添加生产设备" addToView:self.view];
        return;
    }
//    if (!_producePointNameArr || [_producePointNameArr isKindOfClass:[NSNull class]]) {
//        [LTools showMBProgressWithText:@"请添加生产节点" addToView:self.view];
//        return;
//    }
//    if (!spotsArr || [spotsArr isKindOfClass:[NSNull class]]) {
//        [LTools showMBProgressWithText:@"请添加生产节点" addToView:self.view];
//        return;
//    }
    if ([managerPrice isKindOfClass:[NSNull class]] || [managerPrice isEqual:@""] || !managerPrice) {
        [LTools showMBProgressWithText:@"请输入管理者工价" addToView:self.view];
        return;
    }
//    if (!workGroupsArr || [workGroupsArr isKindOfClass:[NSNull class]]) {
//        [LTools showMBProgressWithText:@"请添加所需工人" addToView:self.view];
//        return;
//    }
    if (_bomsImageArr.count == 0 || !_bomsImageArr) {
        [LTools showMBProgressWithText:@"请选择Bom资料" addToView:self.view];
        return;
    }
    if ([str6 isKindOfClass:[NSNull class]] || [str6 isEqual:@""] || !str6) {
        [LTools showMBProgressWithText:@"请输入物料编号" addToView:self.view];
        return;
    }
    if ([_areaId isKindOfClass:[NSNull class]] || [_areaId isEqual:@""] || !_areaId) {
        [LTools showMBProgressWithText:@"请选择发布区域" addToView:self.view];
        return;
    }
    if ([acceptAreaStr isKindOfClass:[NSNull class]] || [acceptAreaStr isEqual:@""] || !acceptAreaStr) {
        [LTools showMBProgressWithText:@"请输入收货地址" addToView:self.view];
        return;
    }
    if ([str4 isKindOfClass:[NSNull class]] || [str4 isEqual:@""] || !str4) {
        [LTools showMBProgressWithText:@"请输入快递费用" addToView:self.view];
        return;
    }
    if ([str5 isKindOfClass:[NSNull class]] || [str5 isEqual:@""] || !str5) {
        [LTools showMBProgressWithText:@"请输入包装费用" addToView:self.view];
        return;
    }
    
    if ([packDetailTextView.text isEqual:@""]) {
        [LTools showMBProgressWithText:@"请输入包装说明" addToView:self.view];
        return;
    }
    WEAKSELF;
    if (!_contractorDic || ![_contractorDic isKindOfClass:[NSNull class]]) {
        NSMutableArray *bomImageArr = @[].mutableCopy;
        [HttpTool uploadImageWithPath:SERVER_PictureUpload params:nil thumbName:@"file" ImageAry:_bomsImageArr success:^(id json)
         {
             if ([json server_Getcodecheck])
             {
                 NSArray *imageStringArr = [NSMutableArray arrayWithArray:json[@"data"]];
                 for (int i = 0; i < imageStringArr.count; i++) {
                     NSDictionary *dic = @{@"url" : imageStringArr[i]};
                     [bomImageArr addObject:dic];
                 }
                 
//                 if (simplePackIsSelect) {
//                     _dic = @{@"type" : @"2", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"area" : @{@"id" : _areaId}, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"bomNum":str6};
//                 } else {
                     if (rightBtnIsSelect) {
                         if (_imageArr.count == 0 || !_imageArr) {
                             [LTools showMBProgressWithText:@"请选择包装图纸" addToView:self.view];
                             return;
                         }
                         NSMutableArray *packImageArr = @[].mutableCopy;
                         [HttpTool uploadImageWithPath:SERVER_PictureUpload params:nil thumbName:@"file" ImageAry:_imageArr success:^(id json)
                          {
                              if ([json server_Getcodecheck])
                              {
                                  NSArray *imageStringArr = [NSMutableArray arrayWithArray:json[@"data"]];
                                  for (int i = 0; i < imageStringArr.count; i++) {
                                      NSDictionary *dic = @{@"url" : imageStringArr[i]};
                                      [packImageArr addObject:dic];
                                  }
                                  if (simplePackIsSelect) {
                                      _dic = @{@"type" : @"2", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"area" : @{@"id" : _areaId}, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"packImgs" : packImageArr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"bomNum":str6};
                                  } else {
                                      _dic = @{@"type" : @"2", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"area" : @{@"id" : _areaId}, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"wrapperType" : wrapperTypeStr, @"packImgs" : packImageArr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"bomNum":str6};
                                  }
                              }
                          } failure:^(NSError *error) {
                              //         [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
                              [LTools showMBProgressWithText:@"上传失败,请重试" addToView:self.view];
                          } progress:^(CGFloat progress) {
                              
                          }];
                         
                     } else {
                         if (simplePackIsSelect) {
                             _dic = @{@"type" : @"2", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"area" : @{@"id" : _areaId}, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"bomNum":str6};
                         } else {
                             _dic = @{@"type" : @"2", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"area" : @{@"id" : _areaId}, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"wrapperType" : wrapperTypeStr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"bomNum":str6};
                         }
                     }
//                 }
                 [MBProgressHUD showHUDAddedTo:self.view animated:YES];
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                     [HYBaseHandler requestSendRequirementParmers:_dic Success:^(id obj)
                      {
                          [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
                          if ([obj server_Getcodecheck])
                          {
                              NSLog(@"%@", obj);
                              [LTools showMBProgressWithText:@"保存成功" addToView:weakSelf.view];
                              dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                                  SelectFactoryViewController *selectFactoryVC = [[SelectFactoryViewController alloc] init];
                                  selectFactoryVC.projectId = obj[@"data"][@"id"];
                                  [self.navigationController pushViewController:selectFactoryVC animated:YES];
                              });
                          }
                          else
                          {
                              [LTools showMBProgressWithText:obj[@"msg"] addToView:weakSelf.view];
                          }
                      } failed:^(NSError *error) {
                          [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
                      }];
                 });
                 
             }
         } failure:^(NSError *error) {
             //         [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
             [LTools showMBProgressWithText:@"上传失败,请重试" addToView:self.view];
         } progress:^(CGFloat progress) {
             
         }];
    } else {
        
        NSMutableArray *bomImageArr = @[].mutableCopy;
        [HttpTool uploadImageWithPath:SERVER_PictureUpload params:nil thumbName:@"file" ImageAry:_bomsImageArr success:^(id json)
         {
             if ([json server_Getcodecheck])
             {
                 NSArray *imageStringArr = [NSMutableArray arrayWithArray:json[@"data"]];
                 for (int i = 0; i < imageStringArr.count; i++) {
                     NSDictionary *dic = @{@"url" : imageStringArr[i]};
                     [bomImageArr addObject:dic];
                 }
                 NSString *productId;
                 if ([selectProduceModel.ID isEqualToString:@""] || [selectProduceModel isKindOfClass:[NSNull class]] || !selectProduceModel.ID) {
                     productId = @"0";
                 } else {
                     productId = selectProduceModel.ID;
                 }
                 
                 if (simplePackIsSelect) {
                     _dic = @{@"type" : @"1", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"contractor" : _contractorDic, @"bomNum":str6};
                 } else {
                     if (rightBtnIsSelect) {
                         NSMutableArray *packImageArr = @[].mutableCopy;
                         [HttpTool uploadImageWithPath:SERVER_PictureUpload params:nil thumbName:@"file" ImageAry:_imageArr success:^(id json)
                          {
                              if ([json server_Getcodecheck])
                              {
                                  NSArray *imageStringArr = [NSMutableArray arrayWithArray:json[@"data"]];
                                  for (int i = 0; i < imageStringArr.count; i++) {
                                      NSDictionary *dic = @{@"url" : imageStringArr[i]};
                                      [packImageArr addObject:dic];
                                  }
                                  _dic = @{@"type" : @"1", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"wrapperType" : wrapperTypeStr, @"packImgs" : packImageArr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"contractor" : _contractorDic, @"bomNum":str6};
                              }
                          } failure:^(NSError *error) {
                              //         [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
                              [LTools showMBProgressWithText:@"上传失败,请重试" addToView:self.view];
                          } progress:^(CGFloat progress) {
                              
                          }];
                         
                     } else {
                         _dic = @{@"type" : @"1", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"wrapperType" : wrapperTypeStr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"contractor" : _contractorDic, @"bomNum":str6};
                     }
                 }
                 [MBProgressHUD showHUDAddedTo:self.view animated:YES];
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                     [HYBaseHandler requestSendRequirementParmers:_dic Success:^(id obj)
                      {
                          [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
                          if ([obj server_Getcodecheck])
                          {
                              NSLog(@"%@", obj);
                              [LTools showMBProgressWithText:@"保存成功" addToView:weakSelf.view];
                              dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                                  [self.navigationController popViewControllerAnimated:YES];
                              });
                          }
                          else
                          {
                              [LTools showMBProgressWithText:obj[@"msg"] addToView:weakSelf.view];
                          }
                      } failed:^(NSError *error) {
                          [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
                      }];
                     
                 });
                 
             }
         } failure:^(NSError *error) {
             //         [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
             [LTools showMBProgressWithText:@"上传失败,请重试" addToView:self.view];
         } progress:^(CGFloat progress) {
             
         }];
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 7;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (section == 0) {
        return productionNameArr.count;
    } else if (section == 1) {
        return 1;
    } else if (section == 2) {
        return _produceMachineNameArr.count + 1;
    } else if (section == 3) {
        return _produceWorkerNameArr.count + 2;
    } else if (section == 4) {
        return _producePointNameArr.count + 2;
    } else if (section == 5) {
        return nameArr.count;
    } else if (section == 6) {
        if (packPictureIsHas) {
            return 3;
        } else {
            return 2;
        }
    } else {
        return 0;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 6) {
        if (packPictureIsHas) {
            if (indexPath.row == 2) {
                return _height;
            }
        } else {
            if (indexPath.row == 1) {
                return _height;
            }
        }
    }
    return 44;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return 0;
    } else {
        return 5*displaywidth;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.000001;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//    ProjectDetailModel *detailModel = _projectDetailArr[0];
    if (indexPath.section == 0) {
        NSString *ID = @"cell1";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
        }
        cell.textLabel.text = productionNameArr[indexPath.row];
        
        if (![self.view viewWithTag:indexPath.row + 100]) {
            if (indexPath.row == 0) {
                CGFloat width = SCREEN_WIDTH - 150;
                UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - width - 50, 0, width, 44)];
                textField.backgroundColor = [UIColor clearColor];
                textField.delegate = self;
                textField.tag = 100;
                textField.font = [UIFont systemFontOfSize:15];
                textField.textAlignment = NSTextAlignmentLeft;
                textField.textColor = UIColorHexValue(0xB3B3B3);
                textField.placeholder = @"请输入项目名称";
                [cell.contentView addSubview:textField];
            } else if (indexPath.row == 1) {
                if (!productTipLabel) {
                    CGFloat width = SCREEN_WIDTH - 150;
                    productTipLabel = [ZCControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH - width - 50, 0, width, 44) Font:15 Text:@"请选择生产类型" Color:UIColorHexValue(0xB3B3B3)];
                    [cell.contentView addSubview:productTipLabel];
                }
            } else if (indexPath.row == 2) {
                CGFloat width = SCREEN_WIDTH - 150;
                UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - width - 50, 0, width, 44)];
                textField.backgroundColor = [UIColor clearColor];
                textField.delegate = self;
                textField.tag = 102;
                textField.font = [UIFont systemFontOfSize:15];
                textField.textAlignment = NSTextAlignmentLeft;
                textField.textColor = UIColorHexValue(0xB3B3B3);
                if (!dayLabel) {
                    dayLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 33, 0, 33, 44)];
                    dayLabel.text = @"(元)";
                    dayLabel.textColor = UIColorHexValue(0xB3B3B3);
                    dayLabel.backgroundColor = [UIColor whiteColor];
                    dayLabel.font = [UIFont systemFontOfSize:15];
                    dayLabel.textAlignment = NSTextAlignmentCenter;
                    [cell.contentView addSubview:dayLabel];
                }
                textField.placeholder = @"请输入项目总金额";
                textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
                [cell.contentView addSubview:textField];
            } else if (indexPath.row == 3) {
                CGFloat width = (SCREEN_WIDTH-100-30)/2;
                UITextField *startTextField = [[UITextField alloc] initWithFrame:CGRectMake(100, 0, width, 44)];
                UILabel *wordLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(startTextField.frame) + 5, 0, 20, 44)];
                UITextField *endTextField = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(wordLabel.frame) + 5, 0, width, 44)];
                startTextField.delegate = self;
                startTextField.tag = 103;
                startTextField.font = [UIFont systemFontOfSize:15];
                startTextField.textAlignment = NSTextAlignmentCenter;
                startTextField.textColor = UIColorHexValue(0xB3B3B3);
                startTextField.placeholder = @"请输入开始时间";
                startTextField.enabled = NO;
                
                endTextField.delegate = self;
                endTextField.tag = 104;
                endTextField.font = [UIFont systemFontOfSize:15];
                endTextField.textAlignment = NSTextAlignmentCenter;
                endTextField.textColor = UIColorHexValue(0xB3B3B3);
                endTextField.placeholder = @"请输入结束时间";
                endTextField.enabled = NO;
                wordLabel.text = @"到";
                wordLabel.textColor = UIColorHexValue(0x4D4D4D);
                wordLabel.backgroundColor = [UIColor whiteColor];
                wordLabel.font = [UIFont systemFontOfSize:15];
                wordLabel.textAlignment = NSTextAlignmentCenter;
                [cell.contentView addSubview:wordLabel];
                
                UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 43, SCREEN_WIDTH - 15, 1)];
                lineLabel.backgroundColor = RGB(238, 239, 238);
                [cell.contentView addSubview:lineLabel];
                [cell.contentView addSubview:startTextField];
                [cell.contentView addSubview:endTextField];
                UIButton *startBtn = [ZCControl createButtonWithFrame:CGRectMake(100, 0, width, 44) ImageName:nil Target:self Action:@selector(onClickStartBtn) Title:nil Font:10];
                startBtn.backgroundColor = [UIColor clearColor];
                [cell.contentView addSubview:startBtn];
                UIButton *endBtn = [ZCControl createButtonWithFrame:CGRectMake(CGRectGetMaxX(wordLabel.frame) + 5, 0, width, 44) ImageName:nil Target:self Action:@selector(onClickEndBtn) Title:nil Font:10];
                endBtn.backgroundColor = [UIColor clearColor];
                [cell.contentView addSubview:endBtn];
            }
            
        }
        
        if (indexPath.row == 1) {
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.detailTextLabel.text = produceType;
            cell.detailTextLabel.textColor = UIColorHexValue(0xB3B3B3);
        } else {
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        cell.textLabel.font = [UIFont systemFontOfSize:15];
        cell.textLabel.textColor = UIColorHexValue(0x4D4D4D);
        UITextField *textField = [cell.contentView viewWithTag:100];
        UITextField *textField2 = [cell.contentView viewWithTag:102];
        UITextField *textField3 = [cell.contentView viewWithTag:103];
        UITextField *textField4 = [cell.contentView viewWithTag:104];
        textField.text = projectNameStr;
        textField2.text = projectBudgetStr;
        textField3.text = startTimeStr;
        textField4.text = endTimeStr;
        
        return cell;
    } else if (indexPath.section == 1) {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        if (!cell)
        {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"id"];
        }
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.textLabel.text = @"生产说明";
        cell.detailTextLabel.text = produeDetailStr;
        cell.detailTextLabel.textColor = UIColorHexValue(0xB3B3B3);
        cell.textLabel.font = [UIFont systemFontOfSize:16];
        cell.textLabel.textColor = UIColorHexValue(0x4D4D4D);
        return cell;
    } else if (indexPath.section == 2) {
        if (indexPath.row == 0) {
            NSString *ID = @"cell2";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
            if (!cell) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
            }
            if (!nameLabel) {
                nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH - 100, 44)];
                nameLabel.text = @"生产设备";
                nameLabel.textColor = UIColorHexValue(0x4D4D4D);
                nameLabel.backgroundColor = [UIColor whiteColor];
                nameLabel.font = [UIFont systemFontOfSize:16];
                nameLabel.textAlignment = NSTextAlignmentLeft;
                [cell.contentView addSubview:nameLabel];
            }
            if (!addProducePointBtn) {
                addProducePointBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 50, 0, 50, 44)];
                addProducePointBtn.backgroundColor = [UIColor whiteColor];
                [addProducePointBtn setImage:[UIImage imageNamed:@"jiahao"] forState:UIControlStateNormal];
                [addProducePointBtn addTarget:self action:@selector(onClickAddProduceMachineBtn:) forControlEvents:UIControlEventTouchUpInside];
                [cell.contentView addSubview:addProducePointBtn];
                UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 43, SCREEN_WIDTH, 1)];
                lineLabel.backgroundColor = RGB(238, 239, 238);
                [cell.contentView addSubview:lineLabel];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            
            return cell;
        } else {
            ProducePointTableViewCell *cell = [[NSBundle mainBundle] loadNibNamed:@"ProducePointTableViewCell" owner:self options:nil].lastObject;
            
            cell.producePointNameLabel.text = _produceMachineNameArr[indexPath.row - 1];
            cell.numberTextField.textColor = UIColorHexValue(0xB3B3B3);
            cell.numberTextField.layer.borderColor = UIColorHexValue(0xB3B3B3).CGColor;
            cell.numberTextField.layer.borderWidth = 1;
            cell.numberTextField.tag = 1000 + indexPath.row;
            cell.numberTextField.text = _machineNumberArr[indexPath.row - 1];
            cell.numberTextField.delegate = self;
            cell.numberTextField.keyboardType = UIKeyboardTypePhonePad;
            cell.minusBtn.layer.borderColor = UIColorHexValue(0xB3B3B3).CGColor;
            cell.minusBtn.layer.borderWidth = 1;
            cell.minusBtn.tag = indexPath.row + 500;
            [cell.minusBtn addTarget:self action:@selector(onClickMinusNumberBtn:) forControlEvents:UIControlEventTouchUpInside];
            cell.addBtn.layer.borderColor = UIColorHexValue(0xB3B3B3).CGColor;
            cell.addBtn.layer.borderWidth = 1;
            cell.addBtn.tag = indexPath.row + 500;
            [cell.addBtn addTarget:self action:@selector(onClickAddNumberBtn:) forControlEvents:UIControlEventTouchUpInside];
            cell.deleteBtn.tag = indexPath.row;
            [cell.deleteBtn addTarget:self action:@selector(deleteProduceMachine:) forControlEvents:UIControlEventTouchUpInside];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            if (indexPath.row == _produceMachineNameArr.count) {
                cell.lineLabel.hidden = YES;
            }
            
            return cell;
        }
        
    } else if (indexPath.section == 3) {
        if (indexPath.row == 0) {
            NSString *ID = @"cell3";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
            if (!cell) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
            }
            if (!workerNameLabel) {
                workerNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH - 100, 44)];
                workerNameLabel.text = @"所需工人";
                workerNameLabel.textColor = UIColorHexValue(0x4D4D4D);
                workerNameLabel.backgroundColor = [UIColor whiteColor];
                workerNameLabel.font = [UIFont systemFontOfSize:16];
                workerNameLabel.textAlignment = NSTextAlignmentLeft;
                [cell.contentView addSubview:workerNameLabel];
            }
            if (!workerAddProducePointBtn) {
                workerAddProducePointBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 100-12, 0, 100, 44)];
                workerAddProducePointBtn.backgroundColor = [UIColor whiteColor];
                workerAddProducePointBtn.enabled = NO;
                [workerAddProducePointBtn addTarget:self action:@selector(onClickAddProduceWorkerBtn:) forControlEvents:UIControlEventTouchUpInside];
                workerAddProducePointBtn.titleLabel.font = [UIFont systemFontOfSize:16];
                [workerAddProducePointBtn setTitleColor:UIColorHexValue(0x4D4D4D) forState:UIControlStateNormal];
                workerAddProducePointBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
                [cell.contentView addSubview:workerAddProducePointBtn];
                UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 43, SCREEN_WIDTH, 1)];
                lineLabel.backgroundColor = RGB(238, 239, 238);
                [cell.contentView addSubview:lineLabel];
            }
            NSInteger num = 0;
            for (int i = 0; i < _workNumberArr.count; i++) {
                NSInteger workNum = [_workNumberArr[i] integerValue];
                num = num + workNum;
            }
            [workerAddProducePointBtn setTitle:[NSString stringWithFormat:@"%ld人", num + 1] forState:UIControlStateNormal];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            
            return cell;
        } else {
            ProducePointTableViewCell *cell = [[NSBundle mainBundle] loadNibNamed:@"ProducePointTableViewCell" owner:self options:nil].lastObject;
            cell.minusBtn.hidden = YES;
            cell.addBtn.hidden = YES;
            cell.deleteBtn.hidden = YES;
            cell.numberTextField.enabled = NO;
            cell.numberTextField.borderStyle = UITextBorderStyleNone;
            cell.numberTextField.textAlignment = NSTextAlignmentRight;
            cell.numberTextField.frame = CGRectMake(cell.contentView.frame.size.width - cell.numberTextField.frame.size.width - 12, cell.numberTextField.frame.origin.y, cell.numberTextField.frame.size.width, cell.numberTextField.frame.size.height);
            if (indexPath.row == 1) {
                cell.producePointNameLabel.text = @"管理者";
                cell.numberTextField.text = @"x1";
            } else {
                cell.producePointNameLabel.text = _produceWorkerNameArr[indexPath.row - 2];
                cell.numberTextField.text = [NSString stringWithFormat:@"x%@", _workNumberArr[indexPath.row - 2]];
            }
            cell.numberTextField.textColor = UIColorHexValue(0x4D4D4D);
//            cell.numberTextField.layer.borderColor = UIColorHexValue(0xB3B3B3).CGColor;
//            cell.numberTextField.layer.borderWidth = 1;
            cell.numberTextField.tag = 2000 + indexPath.row;
            cell.numberTextField.delegate = self;
            cell.numberTextField.keyboardType = UIKeyboardTypePhonePad;
            cell.minusBtn.layer.borderColor = UIColorHexValue(0xB3B3B3).CGColor;
            cell.minusBtn.layer.borderWidth = 1;
            cell.minusBtn.tag = indexPath.row + 500;
            [cell.minusBtn addTarget:self action:@selector(onClickMinusWorkerNumberBtn:) forControlEvents:UIControlEventTouchUpInside];
            cell.addBtn.layer.borderColor = UIColorHexValue(0xB3B3B3).CGColor;
            cell.addBtn.layer.borderWidth = 1;
            cell.addBtn.tag = indexPath.row + 500;
            [cell.addBtn addTarget:self action:@selector(onClickAddWorkerNumberBtn:) forControlEvents:UIControlEventTouchUpInside];
            cell.deleteBtn.tag = indexPath.row;
            [cell.deleteBtn addTarget:self action:@selector(deleteProduceWorker:) forControlEvents:UIControlEventTouchUpInside];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            if (indexPath.row == _produceMachineNameArr.count) {
                cell.lineLabel.hidden = YES;
            }
            
            return cell;
        }
    } else if (indexPath.section == 4) {
        if (indexPath.row == 0) {
            NSString *ID = @"cell4";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
            if (!cell) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
            }
            if (!jobNameLabel) {
                jobNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH - 100, 44)];
                jobNameLabel.text = @"生产节点";
                jobNameLabel.textColor = UIColorHexValue(0x4D4D4D);
                jobNameLabel.backgroundColor = [UIColor whiteColor];
                jobNameLabel.font = [UIFont systemFontOfSize:16];
                jobNameLabel.textAlignment = NSTextAlignmentLeft;
                [cell.contentView addSubview:jobNameLabel];
            }
            if (!jobAddProducePointBtn) {
                jobAddProducePointBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 50, 0, 50, 44)];
                jobAddProducePointBtn.backgroundColor = [UIColor whiteColor];
                [jobAddProducePointBtn setImage:[UIImage imageNamed:@"jiahao"] forState:UIControlStateNormal];
                [jobAddProducePointBtn addTarget:self action:@selector(onClickAddProducePointBtn:) forControlEvents:UIControlEventTouchUpInside];
                [cell.contentView addSubview:jobAddProducePointBtn];
                UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 43, SCREEN_WIDTH, 1)];
                lineLabel.backgroundColor = RGB(238, 239, 238);
                [cell.contentView addSubview:lineLabel];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            
            return cell;
        } else {
            ProdoceJobDescriptionTableViewCell *cell = [[NSBundle mainBundle] loadNibNamed:@"ProdoceJobDescriptionTableViewCell" owner:self options:nil].lastObject;
            cell.jobDescriptionTextField.delegate = self;
            if (indexPath.row == 1) {
                [cell.signBtn setImage:[UIImage imageNamed:@"guanlizhe"] forState:UIControlStateNormal];
                cell.jobDescriptionTextField.hidden = YES;
                cell.deleteBtn.hidden = YES;
                cell.nameLabel.text = @"管理者";
                cell.priceLabel.frame = CGRectMake(cell.priceLabel.frame.origin.x, cell.priceLabel.frame.origin.y, cell.contentView.frame.size.width-cell.priceLabel.frame.origin.x-30, cell.priceLabel.frame.size.height);
                if (managerPrice.length>0) {
                    cell.priceLabel.text = [NSString stringWithFormat:@"%@元/小时", managerPrice];
                } else {
                    cell.priceLabel.textAlignment = NSTextAlignmentRight;
                    cell.priceLabel.text = @"设置管理者工价";
                }
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            } else {
                if (_producePointNameArr.count > 0) {
                    ProducePointModel *model = _producePointNameArr[indexPath.row - 2];
                    cell.nameLabel.text = model.nameStr;
                    cell.jobDescriptionTextField.text = spotDetailArr[indexPath.row - 2];
                    cell.priceLabel.text = [NSString stringWithFormat:@"%@元/小时", model.priceStr];
                }
                cell.jobDescriptionTextField.textColor = UIColorHexValue(0xB3B3B3);
                cell.jobDescriptionTextField.delegate = self;
                cell.jobDescriptionTextField.tag = 3000+indexPath.row;
                
                cell.deleteBtn.tag = indexPath.row;
                [cell.deleteBtn addTarget:self action:@selector(deleteProducePoint:) forControlEvents:UIControlEventTouchUpInside];
                [cell.signBtn setTitle:[NSString stringWithFormat:@"%ld", indexPath.row - 1] forState:UIControlStateNormal];
                
            }
            if (indexPath.row == _producePointNameArr.count + 1) {
                cell.lineLabel.hidden = YES;
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            
            return cell;
        }
    } else if (indexPath.section == 5) {
        UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
        if (_contractorDic) {
            if (indexPath.row == 0 || indexPath.row == 1 || indexPath.row == 2) {
                if (indexPath.row == 0) {
                    cell.detailTextLabel.text = [NSString stringWithFormat:@"已选%ld张", _bomsImageArr.count];
                    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                }
                if (indexPath.row == 1) {
                    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(110, 0, SCREEN_WIDTH - 110 - 33, 44)];
                    textField.backgroundColor = [UIColor clearColor];
                    textField.delegate = self;
                    textField.tag = indexPath.row + 600;
                    textField.textAlignment = NSTextAlignmentLeft;
                    textField.textColor = UIColorHexValue(0xB3B3B3);
                    textField.font = [UIFont systemFontOfSize:14];
                    if (indexPath.row == 1) {
                        textField.placeholder = @"请输入物料编号";
                    }
                    textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
                    [cell.contentView addSubview:textField];
                }
                if (indexPath.row == 2) {
                    if (acceptAreaStr.length>0) {
                        cell.detailTextLabel.text = acceptAreaStr;
                    } else {
                        addressLabel = [ZCControl createLabelWithFrame:CGRectMake(110, 0, SCREEN_WIDTH - 110 - 33, 44) Font:14 Text:@"请输入收货地址" Color:UIColorHexValue(0xB3B3B3)];
                        [cell.contentView addSubview:addressLabel];
                    }
                    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                }
            } else {
                if (indexPath.row == 3 || indexPath.row == 4) {
                    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(110, 0, SCREEN_WIDTH - 110 - 33, 44)];
                    textField.backgroundColor = [UIColor clearColor];
                    textField.delegate = self;
                    textField.tag = indexPath.row + 600;
                    textField.textAlignment = NSTextAlignmentLeft;
                    textField.textColor = UIColorHexValue(0xB3B3B3);
                    textField.font = [UIFont systemFontOfSize:14];
                    if (indexPath.row == 3) {
                        textField.placeholder = @"请输入快递费用";
                    } else if (indexPath.row == 4) {
                        textField.placeholder = @"请输入包装费用";
                    }
                    textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
                    [cell.contentView addSubview:textField];
                    UILabel *moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 33, 0, 33, 44)];
                    moneyLabel.text = @"(元)";
                    moneyLabel.textColor = UIColorHexValue(0xB3B3B3);
                    moneyLabel.backgroundColor = [UIColor whiteColor];
                    moneyLabel.font = [UIFont systemFontOfSize:15];
                    moneyLabel.textAlignment = NSTextAlignmentCenter;
                    [cell.contentView addSubview:moneyLabel];
                }
                
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                UITextField *textField = [cell.contentView viewWithTag:603];
                UITextField *textField1 = [cell.contentView viewWithTag:604];
                UITextField *textField2 = [cell.contentView viewWithTag:601];
                textField.text = str4;
                textField1.text = str5;
                textField2.text = str6;
            }
        } else {
            if (indexPath.row == 0 || indexPath.row == 1 || indexPath.row == 2 || indexPath.row == 3) {
                if (indexPath.row == 0) {
                    cell.detailTextLabel.text = [NSString stringWithFormat:@"已选%ld张", _bomsImageArr.count];
                    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                }
                if (indexPath.row == 1) {
                    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(110, 0, SCREEN_WIDTH - 110 - 33, 44)];
                    textField.backgroundColor = [UIColor clearColor];
                    textField.delegate = self;
                    textField.tag = indexPath.row + 600;
                    textField.textAlignment = NSTextAlignmentLeft;
                    textField.textColor = UIColorHexValue(0xB3B3B3);
                    textField.font = [UIFont systemFontOfSize:14];
                    if (indexPath.row == 1) {
                        textField.placeholder = @"请输入物料编号";
                    }
                    textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
                    [cell.contentView addSubview:textField];
                }
                if (indexPath.row == 2) {
                    if (sendAreaStr.length>0) {
                        cell.detailTextLabel.text = sendAreaStr;
                    } else {
                        areaLabel = [ZCControl createLabelWithFrame:CGRectMake(110, 0, SCREEN_WIDTH - 110 - 33, 44) Font:14 Text:@"请选择区域" Color:UIColorHexValue(0xB3B3B3)];
                        [cell.contentView addSubview:areaLabel];
                    }
                    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                } else if (indexPath.row == 3) {
                    if (acceptAreaStr.length>0) {
                        cell.detailTextLabel.text = acceptAreaStr;
                    } else {
                        addressLabel = [ZCControl createLabelWithFrame:CGRectMake(110, 0, SCREEN_WIDTH - 110 - 33, 44) Font:14 Text:@"请输入收货地址" Color:UIColorHexValue(0xB3B3B3)];
                        [cell.contentView addSubview:addressLabel];
                    }
                    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                }
            } else {
                if (indexPath.row == 4 || indexPath.row == 5) {
                    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(110, 0, SCREEN_WIDTH - 110 - 33, 44)];
                    textField.backgroundColor = [UIColor clearColor];
                    textField.delegate = self;
                    textField.tag = indexPath.row + 600;
                    textField.textAlignment = NSTextAlignmentLeft;
                    textField.textColor = UIColorHexValue(0xB3B3B3);
                    textField.font = [UIFont systemFontOfSize:14];
                    if (indexPath.row == 4) {
                        textField.placeholder = @"请输入快递费用";
                    } else if (indexPath.row == 5) {
                        textField.placeholder = @"请输入包装费用";
                    }
                    textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
                    [cell.contentView addSubview:textField];
                    UILabel *moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 33, 0, 33, 44)];
                    moneyLabel.text = @"(元)";
                    moneyLabel.textColor = UIColorHexValue(0xB3B3B3);
                    moneyLabel.backgroundColor = [UIColor whiteColor];
                    moneyLabel.font = [UIFont systemFontOfSize:15];
                    moneyLabel.textAlignment = NSTextAlignmentCenter;
                    [cell.contentView addSubview:moneyLabel];
                }
                
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            UITextField *textField = [cell.contentView viewWithTag:604];
            UITextField *textField1 = [cell.contentView viewWithTag:605];
            UITextField *textField2 = [cell.contentView viewWithTag:601];
            textField.text = str4;
            textField1.text = str5;
            textField2.text = str6;
        }
        
        cell.textLabel.textColor = UIColorHexValue(0x4D4D4D);
        cell.textLabel.font = [UIFont systemFontOfSize:15];
        cell.textLabel.text = nameArr[indexPath.row];
        cell.detailTextLabel.textColor = UIColorHexValue(0xB3B3B3);
        cell.detailTextLabel.font = [UIFont systemFontOfSize:14];
        
        return cell;
    } else if (indexPath.section == 6) {
        UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
        if (indexPath.row == 0) {
            cell.textLabel.text = @"包装详情";
            cell.textLabel.textColor = UIColorHexValue(0x4D4D4D);
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        NSInteger numRow;
        if (packPictureIsHas) {
            if (indexPath.row == 1) {
                cell.detailTextLabel.text = [NSString stringWithFormat:@"已选%ld张", _imageArr.count];
                cell.textLabel.text = @"包装图纸";
                cell.textLabel.textColor = UIColorHexValue(0x4D4D4D);
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            }
            numRow = 2;
        } else {
            numRow = 1;
        }
        if (indexPath.row == numRow) {
            simplePackBtn = [ZCControl createButtonWithFrame:CGRectMake(10, 10, 80, 30) ImageName:nil Target:self Action:@selector(onClickSimplePackBtn) Title:@"简易包装" Font:12];
            simplePackBtn.layer.cornerRadius = 5;
            simplePackBtn.layer.masksToBounds = YES;
            if (simplePackIsSelect) {
                simplePackBtn.backgroundColor = ThemeColor;
                [simplePackBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            } else {
                simplePackBtn.layer.borderColor = ThemeColor.CGColor;
                simplePackBtn.layer.borderWidth = 1;
                simplePackBtn.backgroundColor = [UIColor whiteColor];
                [simplePackBtn setTitleColor:ThemeColor forState:UIControlStateNormal];
            }
            [cell.contentView addSubview:simplePackBtn];
            professionPackBtn = [ZCControl createButtonWithFrame:CGRectMake(95, 10, 80, 30) ImageName:nil Target:self Action:@selector(onClickProfessionPackBtn) Title:@"专业包装" Font:12];
            professionPackBtn.layer.cornerRadius = 5;
            professionPackBtn.layer.masksToBounds = YES;
            if (professionPackIsSelect) {
                professionPackBtn.backgroundColor = ThemeColor;
                [professionPackBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            } else {
                professionPackBtn.layer.borderColor = ThemeColor.CGColor;
                professionPackBtn.layer.borderWidth = 1;
                professionPackBtn.backgroundColor = [UIColor whiteColor];
                [professionPackBtn setTitleColor:ThemeColor forState:UIControlStateNormal];
            }
            [cell.contentView addSubview:professionPackBtn];
            
            leftSelectBtn = [ZCControl createButtonWithFrame:CGRectMake(10, 50, 13, 13) ImageName:nil Target:self Action:@selector(onClickProfessionPackBtn) Title:nil Font:12];
            [leftSelectBtn setBackgroundImage:[UIImage imageNamed:@"kk"] forState:UIControlStateNormal];
            [leftSelectBtn addTarget:self action:@selector(onClickLeftSelectBtn:) forControlEvents:UIControlEventTouchUpInside];
            if (leftBtnIsSelect) {
                [leftSelectBtn setImage:[UIImage imageNamed:@"gou"] forState:UIControlStateNormal];
            }
            [cell.contentView addSubview:leftSelectBtn];
            leftSelectLabel = [ZCControl createLabelWithFrame:CGRectMake(30, 40, 60, 33) Font:13 Text:@"自带材料" Color:UIColorHexValue(0x4D4D4D)];
            leftSelectLabel.userInteractionEnabled = YES;
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickLeftSelectLabel)];
            [leftSelectLabel addGestureRecognizer:tap];
            [cell.contentView addSubview:leftSelectLabel];
            
            rightSelectBtn = [ZCControl createButtonWithFrame:CGRectMake(100, 50, 13, 13) ImageName:nil Target:self Action:@selector(onClickProfessionPackBtn) Title:nil Font:12];
            leftSelectBtn.selected = NO;
            [rightSelectBtn setBackgroundImage:[UIImage imageNamed:@"kk"] forState:UIControlStateNormal];
            [rightSelectBtn addTarget:self action:@selector(onClickRightSelectBtn:) forControlEvents:UIControlEventTouchUpInside];
            if (rightBtnIsSelect) {
                [rightSelectBtn setImage:[UIImage imageNamed:@"gou"] forState:UIControlStateNormal];
            }
            [cell.contentView addSubview:rightSelectBtn];
            rightSelectLabel = [ZCControl createLabelWithFrame:CGRectMake(120, 40, 60, 33) Font:13 Text:@"指定材料" Color:UIColorHexValue(0x4D4D4D)];
            rightSelectLabel.userInteractionEnabled = YES;
            UITapGestureRecognizer *rightTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickRightSelectLabel)];
            [rightSelectLabel addGestureRecognizer:rightTap];
            [cell.contentView addSubview:rightSelectLabel];
            
            packDetailTextView = [[UITextView alloc] init];
            packDetailTextView.delegate = self;
            packDetailTextView.layer.borderWidth = 0.5;
            packDetailTextView.layer.borderColor = UIColorHexValue(0x999999).CGColor;
            packDetailTextView.textColor = UIColorHexValue(0xB3B3B3);
            packDetailTextView.font = [UIFont systemFontOfSize:14];
            packDetailTextView.text = _textViewStr;
            packDetailTextView.frame = CGRectMake(10, textViewY, SCREEN_WIDTH - 20, 100);
            [cell.contentView addSubview:packDetailTextView];
            _plaLabel = [ZCControl createLabelWithFrame:CGRectMake(5, 5, 170, 21) Font:14 Text:@"请输入包装说明" Color:UIColorHexValue(0x999999)];
            if (_textViewStr.length > 0) {
                _plaLabel.hidden = YES;
            }
            [packDetailTextView addSubview:_plaLabel];
            [cell.contentView addSubview:packDetailTextView];
            _countLabel = [ZCControl createLabelWithFrame:CGRectMake(packDetailTextView.frame.size.width - 80 - 10, 69, 80, 21) Font:14 Text:@"0/300" Color:UIColorHexValue(0x4D4D4D)];
            _countLabel.textAlignment = NSTextAlignmentRight;
            [packDetailTextView addSubview:_countLabel];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        cell.textLabel.font = [UIFont systemFontOfSize:15];
        cell.detailTextLabel.font = [UIFont systemFontOfSize:14];
        cell.detailTextLabel.textColor = UIColorHexValue(0xB3B3B3);
        
        return cell;
    }
    return nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    WEAKSELF;
    if (indexPath.section == 0) {
        if (indexPath.row == 1) {
            SelectProduceTypeViewController *produceTypeVC = [[SelectProduceTypeViewController alloc] init];
            produceTypeVC.selectProduceTypeBlock = ^(SelectProduceTypeModel *model) {
                produceType = [NSString stringWithFormat:@"%@%@", model.category.name, model.name];
                productTipLabel.hidden = YES;
                selectProduceModel = model;
                [weakSelf.addProductionLineTableView reloadData];
            };
            [self.navigationController pushViewController:produceTypeVC animated:YES];
        }
    }
    if (indexPath.section == 1) {
        FactoryIntroductionViewController *factoryIntroVC = [[FactoryIntroductionViewController alloc] init];
        factoryIntroVC.messageType = PRODUCEDETAILTYPE;
        factoryIntroVC.delegate = self;
        factoryIntroVC.introductionStr = produeDetailStr;
        [self.navigationController pushViewController:factoryIntroVC animated:YES];
    }
    if (indexPath.section == 4) {
        if (indexPath.row == 1) {
            AddPointViewController *addPointVC = [[AddPointViewController alloc] init];
            WEAKSELF;
            addPointVC.addPointBlock = ^(SelectWorkKindModel *selectWorkKindModel, NSString *jobDetailStr, NSString *priceStr) {
                managerPrice = priceStr;
                [weakSelf.addProductionLineTableView reloadData];
            };
            addPointVC.isManager = YES;
            addPointVC.managerPrice = managerPrice;
            [self.navigationController pushViewController:addPointVC animated:YES];
        }
    }
    if (indexPath.section == 5) {
        if (_contractorDic) {
            if (indexPath.row == 0) {
                SelectPictureViewController *selectPictureVC = [[SelectPictureViewController alloc] init];
                selectPictureVC.pictureType = SELECTBOMIMAGETYPE;
                selectPictureVC.selectImageBlock = ^(NSMutableArray *imageArr) {
                    weakSelf.bomsImageArr = imageArr;
                    [weakSelf.addProductionLineTableView reloadData];
                };
                selectPictureVC.imageArr = _bomsImageArr;
                [self.navigationController pushViewController:selectPictureVC animated:YES];
            } else if (indexPath.row == 2) {
                FactoryIntroductionViewController *factoryIntroVC = [[FactoryIntroductionViewController alloc] init];
                factoryIntroVC.messageType = ACCEPTAREATYPE;
                factoryIntroVC.delegate = self;
                factoryIntroVC.introductionStr = acceptAreaStr;
                [self.navigationController pushViewController:factoryIntroVC animated:YES];
            }
        } else {
            if (indexPath.row == 0) {
                SelectPictureViewController *selectPictureVC = [[SelectPictureViewController alloc] init];
                selectPictureVC.pictureType = SELECTBOMIMAGETYPE;
                selectPictureVC.selectImageBlock = ^(NSMutableArray *imageArr) {
                    weakSelf.bomsImageArr = imageArr;
                    [weakSelf.addProductionLineTableView reloadData];
                };
                selectPictureVC.imageArr = _bomsImageArr;
                [self.navigationController pushViewController:selectPictureVC animated:YES];
            } else if (indexPath.row == 2) {
                CloseAreaViewController *closeAreaVC = [[CloseAreaViewController alloc] init];
                closeAreaVC.chooseOnlyblock = ^(NSString *modelID, NSString *addressStr) {
                    areaLabel.hidden = YES;
                    sendAreaStr = addressStr;
                    weakSelf.areaId = modelID;
                    [weakSelf.addProductionLineTableView reloadData];
                };
                [self.navigationController pushViewController:closeAreaVC animated:YES];
            } else if (indexPath.row == 3) {
                FactoryIntroductionViewController *factoryIntroVC = [[FactoryIntroductionViewController alloc] init];
                factoryIntroVC.messageType = ACCEPTAREATYPE;
                factoryIntroVC.delegate = self;
                factoryIntroVC.introductionStr = acceptAreaStr;
                [self.navigationController pushViewController:factoryIntroVC animated:YES];
            }
        }
        
    } else if (indexPath.section == 6) {
        if (packPictureIsHas) {
            if (indexPath.row == 1) {
                SelectPictureViewController *selectPictureVC = [[SelectPictureViewController alloc] init];
                selectPictureVC.pictureType = SELECTPACKIMAGETYPE;
                selectPictureVC.selectImageBlock = ^(NSMutableArray *imageArr) {
                    weakSelf.imageArr = imageArr;
                    [weakSelf.addProductionLineTableView reloadData];
                };
                selectPictureVC.imageArr = _imageArr;
                [self.navigationController pushViewController:selectPictureVC animated:YES];
            }
        }
    }
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

-(void)getFactoryIntroduction:(NSString *)factoryIntro andType:(NSString *)type {
    if ([type isEqualToString:@"PRODUCEDETAILTYPE"]) {
        produeDetailStr = factoryIntro;
    } else {
        addressLabel.hidden = YES;
        acceptAreaStr = factoryIntro;
    }
    
    [self.addProductionLineTableView reloadData];
}

- (void)onClickSimplePackBtn {
    simplePackIsSelect = YES;
    professionPackIsSelect = NO;
    leftSelectBtn.hidden = NO;
    leftSelectLabel.hidden = NO;
    rightSelectBtn.hidden = NO;
    rightSelectLabel.hidden = NO;
    rightBtnIsSelect = NO;
    leftBtnIsSelect = YES;
    packPictureIsHas = NO;
    packDetailTextView.frame = CGRectMake(10, 50, SCREEN_WIDTH - 20, 100);
    textViewY = 73;
    _height = 183;
    packPictureIsHas = NO;
    [_addProductionLineTableView reloadData];
}

- (void)onClickProfessionPackBtn {
    simplePackIsSelect = NO;
    professionPackIsSelect = YES;
    leftSelectBtn.hidden = NO;
    leftSelectLabel.hidden = NO;
    rightSelectBtn.hidden = NO;
    rightSelectLabel.hidden = NO;
    rightBtnIsSelect = NO;
    leftBtnIsSelect = YES;
    packPictureIsHas = NO;
    textViewY = 73;
    _height = 183;
    packPictureIsHas = NO;
    [self onClickLeftSelectLabel];
    [_addProductionLineTableView reloadData];
}

- (void)onClickLeftSelectBtn:(UIButton *)sender {
    rightBtnIsSelect = NO;
    leftBtnIsSelect = YES;
    packPictureIsHas = NO;
    [_addProductionLineTableView reloadData];
}

- (void)onClickRightSelectBtn:(UIButton *)sender {
    rightBtnIsSelect = YES;
    leftBtnIsSelect = NO;
    packPictureIsHas = YES;
    [_addProductionLineTableView reloadData];
}

- (void)onClickLeftSelectLabel {
    rightBtnIsSelect = NO;
    leftBtnIsSelect = YES;
    packPictureIsHas = NO;
    [_addProductionLineTableView reloadData];
}

- (void)onClickRightSelectLabel {
    rightBtnIsSelect = YES;
    leftBtnIsSelect = NO;
    packPictureIsHas = YES;
    [_addProductionLineTableView reloadData];
}

// MARK: UITextViewDelegate

- (void)textViewDidChange:(UITextView *)textView
{
    if (textView.text.length > 0) {
        self.plaLabel.hidden = YES;
    } else {
        self.plaLabel.hidden = NO;
    }
    
    int count;
    count = (int)textView.text.length;
    [self.countLabel setText:[NSString stringWithFormat:@"%d/300", count]];  //countLabel是一个显示剩余可输入数字的label
    
}

//限制textView输入字数
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)text
{
    //这个判断相当于是textfield中的点击return的代理方法
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    
    //在输入过程中 判断加上输入的字符 是否超过限定字数
    NSString *str = [NSString stringWithFormat:@"%@%@", textView.text, text];
    if (str.length > 300)
    {
        self.plaLabel.hidden = YES;
        textView.text = [str substringToIndex:300];
        [self.countLabel setText:@"300/300"];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"输入的内容超过限制" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
        return NO;
    }else{
        NSLog(@"%lu",(unsigned long)textView.text.length);
    }
    return YES;
}

// MARK: 发布
//- (void)saveProductionLine {
////    ProjectDetailModel *detailModel = _projectDetailArr[0];
////    UITextField *textField = [self.view viewWithTag:102];
////    UITextField *textField2 = [self.view viewWithTag:103];
////    UITextField *textField3 = [self.view viewWithTag:104];
//    if (nameArr.count == 4) {
//        textField4 = [self.view viewWithTag:602];
//        textField5 = [self.view viewWithTag:603];
//    } else if (nameArr.count == 5) {
//        textField4 = [self.view viewWithTag:603];
//        textField5 = [self.view viewWithTag:604];
//    }
//
//    NSMutableArray *machinesArr = [NSMutableArray array];
//    for (int i = 0; i < _produceMachineModelArr.count; i++) {
////        ProduceMachinesModel *produceModel = _produceMachineModelArr[i];
//        AddMachineModel *model = _produceMachineModelArr[i];
////        ProducePointTableViewCell *cell = [_addProductionLineTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i + 1 inSection:1]];
//        NSDictionary *dic = @{@"machine" : @{@"id" : model.ID}, @"count" : _machineNumberArr[i]};
//        [machinesArr addObject:dic];
//    }
//    NSMutableArray *spotsArr = [NSMutableArray array];
//    for (int i = 0; i < _producePointNameArr.count; i++) {
//        ProducePointModel *model = _producePointNameArr[i];
//        NSDictionary *dic;
////        if (i==0) {
////            dic = @{@"work" : @{@"id" : model.ID}, @"remark" : model.jobDetailStr, @"manager": @"1"};
////        } else {
//        dic = @{@"work" : @{@"id" : model.ID}, @"remark" : model.jobDetailStr, @"manager": @"0"};
////        }
//        [spotsArr addObject:dic];
//    }
//    NSMutableArray *workGroupsArr = [NSMutableArray array];
//    for (int i = 0; i < _produceWorkerModelArr.count; i++) {
//        WorkModel *model = _produceWorkerModelArr[i];
////        ProducePointTableViewCell *cell = [_addProductionLineTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i + 1 inSection:2]];
//        NSDictionary *dic = @{@"work" : @{@"id" : model.workId}, @"count" : _workNumberArr[i]};
//        [workGroupsArr addObject:dic];
//    }
//    NSString *packTypeStr;
//    NSString *wrapperTypeStr;
//    if (simplePackIsSelect) {
//        packTypeStr = @"1";
//    } else {
//        packTypeStr = @"2";
//        if (leftBtnIsSelect) {
//            wrapperTypeStr = @"1";
//        } else {
//            wrapperTypeStr = @"1";
//        }
//    }
//    if ([projectNameStr isEqualToString:@""]) {
//        [LTools showMBProgressWithText:@"请输入项目名称" addToView:self.view];
//        return;
//    }
//    NSString *productId;
//    if ([selectProduceModel.ID isEqualToString:@""] || [selectProduceModel isKindOfClass:[NSNull class]] || !selectProduceModel.ID) {
//        [LTools showMBProgressWithText:@"请选择生产类型" addToView:self.view];
//        return;
//    } else {
//        productId = selectProduceModel.ID;
//    }
//
//    if ([projectBudgetStr isEqualToString:@""]) {
//        [LTools showMBProgressWithText:@"请输入项目总金额" addToView:self.view];
//        return;
//    }
//    if ([startTimeStr isEqualToString:@""]) {
//        [LTools showMBProgressWithText:@"请输入开始时间" addToView:self.view];
//        return;
//    }
//    if ([endTimeStr isEqualToString:@""]) {
//        [LTools showMBProgressWithText:@"请输入结束时间" addToView:self.view];
//        return;
//    }
//    if ([produeDetailStr isEqualToString:@""]) {
//        [LTools showMBProgressWithText:@"请输入生产说明" addToView:self.view];
//        return;
//    }
//    if (!machinesArr || [machinesArr isKindOfClass:[NSNull class]]) {
//        [LTools showMBProgressWithText:@"请添加生产设备" addToView:self.view];
//        return;
//    }
//    if (!_producePointNameArr || [_producePointNameArr isKindOfClass:[NSNull class]]) {
//        [LTools showMBProgressWithText:@"请添加生产节点" addToView:self.view];
//        return;
//    }
//    if (!spotsArr || [spotsArr isKindOfClass:[NSNull class]]) {
//        [LTools showMBProgressWithText:@"请添加生产节点" addToView:self.view];
//        return;
//    }
//    if (!workGroupsArr || [workGroupsArr isKindOfClass:[NSNull class]]) {
//        [LTools showMBProgressWithText:@"请添加所需工人" addToView:self.view];
//        return;
//    }
//    if (_bomsImageArr.count == 0 || !_bomsImageArr) {
//        [LTools showMBProgressWithText:@"请选择Bom资料" addToView:self.view];
//        return;
//    }
//    if ([_areaId isKindOfClass:[NSNull class]] || [_areaId isEqual:@""]) {
//        [LTools showMBProgressWithText:@"请选择发布区域" addToView:self.view];
//        return;
//    }
//    if ([acceptAreaStr isKindOfClass:[NSNull class]] || [acceptAreaStr isEqual:@""]) {
//        [LTools showMBProgressWithText:@"请输入收货地址" addToView:self.view];
//        return;
//    }
//    if ([str4 isKindOfClass:[NSNull class]] || [str4 isEqual:@""]) {
//        [LTools showMBProgressWithText:@"请输入快递费用" addToView:self.view];
//        return;
//    }
//    if ([str5 isKindOfClass:[NSNull class]] || [str5 isEqual:@""]) {
//        [LTools showMBProgressWithText:@"请输入包装费用" addToView:self.view];
//        return;
//    }
//    if ([str6 isKindOfClass:[NSNull class]] || [str6 isEqual:@""]) {
//        [LTools showMBProgressWithText:@"请输入物料编号" addToView:self.view];
//        return;
//    }
//    if ([packDetailTextView.text isEqual:@""]) {
//        [LTools showMBProgressWithText:@"请输入包装说明" addToView:self.view];
//        return;
//    }
//
//    WEAKSELF;
//    NSMutableArray *bomImageArr = @[].mutableCopy;
//    [HttpTool uploadImageWithPath:SERVER_PictureUpload params:nil thumbName:@"file" ImageAry:_bomsImageArr success:^(id json)
//     {
//         if ([json server_Getcodecheck])
//         {
//             NSArray *imageStringArr = [NSMutableArray arrayWithArray:json[@"data"]];
//             for (int i = 0; i < imageStringArr.count; i++) {
//                 NSDictionary *dic = @{@"url" : imageStringArr[i]};
//                 [bomImageArr addObject:dic];
//             }
//
//             if (simplePackIsSelect) {
//                 _dic = @{@"type" : @"2", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"area" : @{@"id" : _areaId}, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"bomNum":str6};
//             } else {
//                 if (rightBtnIsSelect) {
//                     if (_imageArr.count == 0 || !_imageArr) {
//                         [LTools showMBProgressWithText:@"请选择包装图纸" addToView:self.view];
//                         return;
//                     }
//                     NSMutableArray *packImageArr = @[].mutableCopy;
//                     [HttpTool uploadImageWithPath:SERVER_PictureUpload params:nil thumbName:@"file" ImageAry:_imageArr success:^(id json)
//                      {
//                          if ([json server_Getcodecheck])
//                          {
//                              NSArray *imageStringArr = [NSMutableArray arrayWithArray:json[@"data"]];
//                              for (int i = 0; i < imageStringArr.count; i++) {
//                                  NSDictionary *dic = @{@"url" : imageStringArr[i]};
//                                  [packImageArr addObject:dic];
//                              }
//                              _dic = @{@"type" : @"2", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"area" : @{@"id" : _areaId}, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"wrapperType" : wrapperTypeStr, @"packImgs" : packImageArr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"bomNum":str6};
//                          }
//                      } failure:^(NSError *error) {
//                          //         [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
//                          [LTools showMBProgressWithText:@"上传失败,请重试" addToView:self.view];
//                      } progress:^(CGFloat progress) {
//
//                      }];
//
//                 } else {
//                     _dic = @{@"type" : @"2", @"name" : projectNameStr, @"product" : @{@"id" : productId}, @"remark" : produeDetailStr, @"bomImgs" : bomImageArr, @"area" : @{@"id" : _areaId}, @"deliveryAddress" : acceptAreaStr, @"packType" : packTypeStr, @"wrapperType" : wrapperTypeStr, @"packRemark" : packDetailTextView.text, @"budget" : projectBudgetStr, @"expressFee" : str4, @"packingFee" : str5, @"startDate" : startTimeStr, @"endDate" : endTimeStr, @"machines" : machinesArr, @"workGroups" : workGroupsArr, @"spots" : spotsArr, @"bomNum":str6};
//                 }
//             }
//             [MBProgressHUD showHUDAddedTo:self.view animated:YES];
//             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//                 [HYBaseHandler requestSendRequirementParmers:_dic Success:^(id obj)
//                  {
//                      [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
//                      if ([obj server_Getcodecheck])
//                      {
//                          NSLog(@"%@", obj);
//                          [LTools showMBProgressWithText:@"保存成功" addToView:weakSelf.view];
//                          dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//                              [self.navigationController popViewControllerAnimated:YES];
//                          });
//                      }
//                      else
//                      {
//                          [LTools showMBProgressWithText:obj[@"msg"] addToView:weakSelf.view];
//                      }
//                  } failed:^(NSError *error) {
//                      [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
//                  }];
//             });
//
//         }
//     } failure:^(NSError *error) {
//         //         [MBProgressHUD hideAllHUDsForView:weakSelf.view animated:YES];
//         [LTools showMBProgressWithText:@"上传失败,请重试" addToView:self.view];
//     } progress:^(CGFloat progress) {
//
//     }];
//
//
//}

- (void)onClickAddNumberBtn:(UIButton *)sender {
    ProducePointTableViewCell *cell = [_addProductionLineTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:sender.tag - 500 inSection:2]];
    NSInteger num = [cell.numberTextField.text integerValue];
    num ++;
    cell.numberTextField.text = [NSString stringWithFormat:@"%ld", (long)num];
    _machineNumberArr[sender.tag - 500 - 1] = cell.numberTextField.text;
}

- (void)onClickMinusNumberBtn:(UIButton *)sender {
    ProducePointTableViewCell *cell = [_addProductionLineTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:sender.tag - 500 inSection:2]];
    NSInteger num = [cell.numberTextField.text integerValue];
    if (num != 1) {
        num --;
    }
    cell.numberTextField.text = [NSString stringWithFormat:@"%ld", (long)num];
    _machineNumberArr[sender.tag - 500 - 1] = cell.numberTextField.text;
}

- (void)deleteProduceMachine:(UIButton *)sender {
    if (_produceMachineNameArr.count > 0) {
        [_produceMachineNameArr removeObjectAtIndex:sender.tag - 1];
        [_machineNumberArr removeObjectAtIndex:sender.tag - 1];
        [_produceMachineModelArr removeObjectAtIndex:sender.tag - 1];
    }
    [_addProductionLineTableView reloadData];
}

- (void)onClickAddWorkerNumberBtn:(UIButton *)sender {
    ProducePointTableViewCell *cell = [_addProductionLineTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:sender.tag - 500 inSection:3]];
    NSInteger num = [cell.numberTextField.text integerValue];
    num ++;
    cell.numberTextField.text = [NSString stringWithFormat:@"%ld", (long)num];
    _workNumberArr[sender.tag - 500 - 1] = cell.numberTextField.text;
}

- (void)onClickMinusWorkerNumberBtn:(UIButton *)sender {
    ProducePointTableViewCell *cell = [_addProductionLineTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:sender.tag - 500 inSection:3]];
    NSInteger num = [cell.numberTextField.text integerValue];
    if (num != 1) {
        num --;
    }
    cell.numberTextField.text = [NSString stringWithFormat:@"%ld", (long)num];
    _workNumberArr[sender.tag - 500 - 1] = cell.numberTextField.text;
}

- (void)deleteProduceWorker:(UIButton *)sender {
    [_produceWorkerNameArr removeObjectAtIndex:sender.tag - 1];
    [_workNumberArr removeObjectAtIndex:sender.tag - 1];
    [_produceWorkerModelArr removeObjectAtIndex:sender.tag - 1];
    [_addProductionLineTableView reloadData];
}

- (void)deleteProducePoint:(UIButton *)sender {
    ProducePointModel *model = _producePointNameArr[sender.tag - 2];
    BOOL isSame = NO;
    NSInteger index = 0;
    for (int i = 0; i < _produceWorkerNameArr.count; i++) {
        NSString *nameStr = _produceWorkerNameArr[i];
        if ([nameStr isEqual:model.nameStr]) {
            isSame = YES;
            index = i;
            break;
        } else {
            isSame = NO;
        }
    }
    if (isSame) {
        NSInteger num = [_workNumberArr[index] integerValue];
        if (num == 1) {
            [_produceWorkerNameArr removeObjectAtIndex:sender.tag - 2];
            [_workNumberArr removeObjectAtIndex:sender.tag - 2];
            [_produceWorkerModelArr removeObjectAtIndex:sender.tag - 2];
        } else {
            _workNumberArr[index] = [NSString stringWithFormat:@"%ld", num - 1];
            WorkModel *workModel = _produceWorkerModelArr[index];
            workModel.count = _workNumberArr[index];
            _produceWorkerModelArr[index] = workModel;
        }
    } else {
        [_produceWorkerNameArr removeObjectAtIndex:sender.tag - 2];
        [_workNumberArr removeObjectAtIndex:sender.tag - 2];
        [_produceWorkerModelArr removeObjectAtIndex:sender.tag - 2];
    }
    
    [_producePointNameArr removeObjectAtIndex:sender.tag - 2];
    [spotDetailArr removeObjectAtIndex:sender.tag - 2];
    [_addProductionLineTableView reloadData];
}

- (void)onClickAddProduceWorkerBtn:(UIButton *)sender {
    SpecialWorkerViewController *specialWorkerVC = [[SpecialWorkerViewController alloc] init];
    WEAKSELF;
    specialWorkerVC.addWorkerBlock = ^(SpecialWorkerModel *model) {
        [weakSelf.produceWorkerNameArr addObject:model.name];
        [weakSelf.workNumberArr addObject:@"1"];
        WorkModel *workModel = [[WorkModel alloc] init];
        workModel.workId = model.ID;
        workModel.count = @"1";
        [_produceWorkerModelArr addObject:workModel];
        [weakSelf.addProductionLineTableView reloadData];
    };
    [self.navigationController pushViewController:specialWorkerVC animated:YES];
}

- (void)onClickAddProducePointBtn:(UIButton *)sender {
    AddPointViewController *addPointVC = [[AddPointViewController alloc] init];
    WEAKSELF;
    addPointVC.addPointBlock = ^(SelectWorkKindModel *selectWorkKindModel, NSString *jobDetailStr, NSString *priceStr) {
        _selectWorkKindModel = selectWorkKindModel;
        ProducePointModel *model = [[ProducePointModel alloc] init];
        model.nameStr = selectWorkKindModel.name;
        model.jobDetailStr = jobDetailStr;
        model.ID = selectWorkKindModel.ID;
        model.priceStr = priceStr;
        [spotDetailArr addObject:jobDetailStr];
        [_producePointNameArr addObject:model];
        if (_produceWorkerNameArr.count > 0) {
            BOOL isSame = NO;
            NSInteger index = 0;
            for (int i = 0; i < _produceWorkerNameArr.count; i++) {
                NSString *nameStr = _produceWorkerNameArr[i];
                if ([nameStr isEqual:selectWorkKindModel.name]) {
                    isSame = YES;
                    index = i;
                    break;
                } else {
                    isSame = NO;
                }
            }
            if (isSame) {
                NSInteger num = [_workNumberArr[index] integerValue];
                _workNumberArr[index] = [NSString stringWithFormat:@"%ld", num + 1];
                WorkModel *workModel = _produceWorkerModelArr[index];
                workModel.count = _workNumberArr[index];
                _produceWorkerModelArr[index] = workModel;
            } else {
                [_produceWorkerNameArr addObject:selectWorkKindModel.name];
                [_workNumberArr addObject:@"1"];
                WorkModel *workModel = [[WorkModel alloc] init];
                workModel.workId = model.ID;
                workModel.count = _workNumberArr.lastObject;
                [_produceWorkerModelArr addObject:workModel];
            }
        } else {
            [_produceWorkerNameArr addObject:selectWorkKindModel.name];
            [_workNumberArr addObject:@"1"];
            WorkModel *workModel = [[WorkModel alloc] init];
            workModel.workId = model.ID;
            workModel.count = _workNumberArr.lastObject;
            [_produceWorkerModelArr addObject:workModel];
        }
        
        [weakSelf.addProductionLineTableView reloadData];
    };
    [self.navigationController pushViewController:addPointVC animated:YES];
}

- (void)onClickAddProduceMachineBtn:(UIButton *)sender {
    AddMachineViewController *addMachineVC = [[AddMachineViewController alloc] init];
    WEAKSELF;
    addMachineVC.addMachineBlock = ^(AddMachineModel *addMachineModel) {
        _addMachineModel = addMachineModel;
        if (_produceMachineNameArr.count > 0) {
            BOOL isSame = NO;
            NSInteger index = 0;
            for (int i = 0; i < _produceMachineNameArr.count; i++) {
                NSString *nameStr = _produceMachineNameArr[i];
                if ([nameStr isEqual:addMachineModel.name]) {
                    isSame = YES;
                    index = i;
                    break;
                } else {
                    isSame = NO;
                }
            }
            if (isSame) {
                NSInteger num = [_machineNumberArr[index] integerValue];
                _machineNumberArr[index] = [NSString stringWithFormat:@"%ld", num + 1];
            } else {
                [_produceMachineNameArr addObject:addMachineModel.name];
                [_produceMachineModelArr addObject:addMachineModel];
                [_machineNumberArr addObject:@"1"];
            }
        } else {
            [_produceMachineNameArr addObject:addMachineModel.name];
            [_produceMachineModelArr addObject:addMachineModel];
            [_machineNumberArr addObject:@"1"];
        }
        [weakSelf.addProductionLineTableView reloadData];
    };
    
    [self.navigationController pushViewController:addMachineVC animated:YES];
}

- (void)onClickStartBtn {
    whichPicker = 1;
    [self setupPickerView];
}

- (void)onClickEndBtn {
    whichPicker = 2;
    [self setupPickerView];
}

- (void)setupPickerView {
    PGDatePickManager *datePickManager = [[PGDatePickManager alloc]init];
    datePickManager.isShadeBackgroud = true;
    PGDatePicker *datePicker = datePickManager.datePicker;
    datePicker.delegate = self;
    datePicker.datePickerType = PGPickerViewType1;
    datePicker.isHiddenMiddleText = false;
    datePicker.datePickerMode = PGDatePickerModeDate;
    if (whichPicker == 1) {
        if (endComponent && ![endComponent isKindOfClass:[NSNull class]]) {
            datePicker.minimumDate = [NSDate dateWithTimeIntervalSinceNow:172800];
            datePicker.maximumDate = [NSDate setYear:endComponent.year month:endComponent.month day:endComponent.day - 1];
        }else {
            datePicker.minimumDate = [NSDate dateWithTimeIntervalSinceNow:172800];
        }
    } else {
        if (startComponent && ![startComponent isKindOfClass:[NSNull class]]) {
            datePicker.minimumDate = [NSDate setYear:startComponent.year month:startComponent.month day:startComponent.day + 1];
        }else {
            datePicker.minimumDate = [NSDate dateWithTimeIntervalSinceNow:172800];
        }
    }
    [self presentViewController:datePickManager animated:NO completion:nil];
}

#pragma PGDatePickerDelegate
- (void)datePicker:(PGDatePicker *)datePicker didSelectDate:(NSDateComponents *)dateComponents {
    NSLog(@"dateComponents = %@", dateComponents);
    if (whichPicker == 1) {
        UITextField *textField = [self.view viewWithTag:103];
        textField.text = [NSString stringWithFormat:@"%ld-%ld-%ld", dateComponents.year, dateComponents.month, dateComponents.day];
        startTimeStr = textField.text;
        startComponent = dateComponents;
    } else {
        UITextField *textField = [self.view viewWithTag:104];
        textField.text = [NSString stringWithFormat:@"%ld-%ld-%ld", dateComponents.year, dateComponents.month, dateComponents.day];
        endTimeStr = textField.text;
        endComponent = dateComponents;
    }
}

//// 我们获取那个Cell是被点击的
//- (void)textFieldDidBeginEditing:(UITextField *)textField
//{
//    /* 获取当前cell的位置*/
//    /* 我们进行层次分析
//     * A.superview 则是 cell
//     */
//    scrollViewOffSetY = _addProductionLineTableView.contentOffset.y;
//    CGFloat Hieght = textField.superview.superview.frame.origin.y;
//    /* 获取当前点击Cell的位置*/
//    CGFloat CurrentCellY = Hieght - scrollViewOffSetY;
//    /* 获取剩余高度*/
//    CGFloat lastHeight = [UIScreen mainScreen].bounds.size.height - CurrentCellY-200;
//    remainingDistanceY = lastHeight;
//
//
//}

//- (void)textViewDidBeginEditing:(UITextView *)textView {
//    scrollViewOffSetY = _addProductionLineTableView.contentOffset.y;
//    CGFloat Hieght = textView.superview.superview.frame.origin.y;
//    /* 获取当前点击Cell的位置*/
//    CGFloat CurrentCellY = Hieght - scrollViewOffSetY;
//    /* 获取剩余高度*/
//    CGFloat lastHeight = [UIScreen mainScreen].bounds.size.height - CurrentCellY-200;
//    remainingDistanceY = lastHeight;
//}

//// 我们在获取弹出键盘的高度和在做计算差值偏移
//-(void)jianpantanchu:(NSNotification*)Notification{
//    NSLog(@"%@",Notification);
//    /* 获取键盘的开始高度*/
//    NSDictionary *userInfo = [Notification userInfo];
//    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
//    CGRect keyboardRect = [aValue CGRectValue];
//    CGFloat keyBoardStart = keyboardRect.size.height;
//
//    //    CGFloat keyBoardStart = [Notification.userInfo[@"UIKeyboardFrameBeginUserInfoKey"] CGRectValue].size.height;
//    if (remainingDistanceY < keyBoardStart) {
//        /* 获取差值*/
//        CGFloat differenceValue = keyBoardStart -remainingDistanceY;
//        beforeMigrationY = differenceValue;
//        [_addProductionLineTableView setContentOffset:CGPointMake(0, differenceValue + scrollViewOffSetY) animated:YES];
//    }
//}

// 我们为了防止tableView不能返回原始没有被点击的位置(这是防止用户在键盘弹出的时候，在滑动而造成的混乱)
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    /* 防止错乱停止编辑*/
    [self.view endEditing:YES];
}
//// 最后键盘隐藏，返回点击前的偏移
//-(void)jianpanhuishou:(NSNotification*)Notification{
//    NSLog(@"Hide");
//    [_addProductionLineTableView setContentOffset:CGPointMake(0, scrollViewOffSetY) animated:YES];
//    beforeMigrationY = 0.0;
//}

-(void)keyboardHide:(UITapGestureRecognizer*)tap {
    [self.view endEditing:YES];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    if (textField.isEditing) {
        [textField endEditing:YES];
    }
    return YES;
}

- (void)textFieldDidEndEditing:(UITextField *)textField {
    if (textField.tag >= 1001 && textField.tag < 2000) {
        _machineNumberArr[textField.tag - 1000 - 1] = textField.text;
    }
    if (textField.tag >= 2000 && textField.tag < 3002) {
        _workNumberArr[textField.tag - 2000 - 1] = textField.text;
    }
    if (textField.tag >= 3002) {
        spotDetailArr[textField.tag - 3000 - 2] = textField.text;
    }
    if (_contractorDic) {
        if (textField.tag == 603) {
            str4 = textField.text;
        }
        if (textField.tag == 604) {
            str5 = textField.text;
        }
        if (textField.tag == 601) {
            str6 = textField.text;
        }
    } else {
        if (textField.tag == 604) {
            str4 = textField.text;
        }
        if (textField.tag == 605) {
            str5 = textField.text;
        }
        if (textField.tag == 601) {
            str6 = textField.text;
        }
    }
    
    if (textField.tag == 100) {
        projectNameStr = textField.text;
    }
    if (textField.tag == 102) {
        projectBudgetStr = textField.text;
    }
    if (textField.tag == 103) {
        startTimeStr = textField.text;
    }
    if (textField.tag == 104) {
        endTimeStr = textField.text;
    }
    
}

-(void)textViewDidEndEditing:(UITextView *)textView {
    _textViewStr = textView.text;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
